<template>
  <BasicModal @register="register" :title="title" @ok="handleSubmit">
    <BasicForm @register="registerForm" />
    <p style="color: red; margin-left: 20px"> 提示：将会修改需求明细的全部需求日期 </p>
  </BasicModal>
</template>
<script lang="ts">
  export default defineComponent({
    name: 'pmPuArrivalvouchModal',
  });
</script>
<script setup lang="ts">
  import { defineComponent, ref } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { BasicForm, FormSchema, useForm } from '/@/components/Form';
  const emit = defineEmits(['success', 'register', 'modifyneedDate']);
  const { showMessage } = useMessage();
  let record = ref<any>({});
    const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
    labelWidth: 100,
    schemas: [
        {
          label: '需求日期',
          field: 'needDate',
          component: 'DatePicker',
          componentProps: {
            format: 'YYYY-MM-DD',
            // showTime: { format: 'HH:mm' },
            showTime: false,
            valueFormat: 'YYYY-MM-DD',
          },
          required: true,
        },
      ],
    baseColProps: { lg: 24, md: 24 },
  });
  const [register, { closeModal, setModalProps }] = useModalInner(async (e) => {
    record.value = e;
    await resetFields();
    // setProps({
    //   labelWidth: 120,
    //   schemas: [
    //     {
    //       label: '计划交付日期',
    //       field: 'needDate',
    //       component: 'DatePicker',
    //       componentProps: {
    //         format: 'YYYY-MM-DD HH:mm',
    //         showTime: { format: 'HH:mm' },
    //       },
    //       required: true,
    //     },
    //   ],
    //   baseColProps: { lg: 24, md: 24 },
    // });
  });
  let title = ref<string>('批量修改需求日期');

  // 保存数据
  async function handleSubmit() {
    try {
      const data = await validate();
      setTimeout(closeModal);
      emit('modifyneedDate', data);
    } catch (error: any) {
      if (error && error.errorFields) {
        showMessage('您填写的信息有误，请根据提示修正。');
      }
      console.log('error', error);
    } finally {
      // setModalProps({ confirmLoading: false });
    }
  }
 
</script>
<style scoped>
  .ant-picker {
    width: 80%;
  }
</style>
